/*     */ package com.controller.back;
/*     */ 
/*     */ import base.dao.BaseExample;
/*     */ import base.dao.BaseExample.Criteria;
/*     */ import base.utils.PagingResult;
/*     */ import com.model.Accessory;
/*     */ import com.model.Admin;
/*     */ import com.model.Users;
/*     */ import com.service.AbstractService;
/*     */ import com.service.AccessoryService;
/*     */ import com.service.PosterService;
/*     */ import com.service.UserService;
/*     */ import java.text.ParsePosition;
/*     */ import java.text.SimpleDateFormat;
/*     */ import java.util.ArrayList;
/*     */ import java.util.Date;
/*     */ import java.util.HashMap;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import javax.servlet.http.HttpSession;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ import org.springframework.web.servlet.ModelAndView;
/*     */ import org.springframework.web.servlet.view.json.MappingJacksonJsonView;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"admin"})
/*     */ public class AdminController
/*     */ {
/*     */   @Autowired
/*     */   private UserService userService;
/*     */   @Autowired
/*     */   private AccessoryService accessoryService;
/*     */   @Autowired
/*     */   private PosterService posterService;
/*     */   @Autowired
/*     */   private AbstractService abstractService;
/*     */   
/*     */   @RequestMapping({"index"})
/*     */   public ModelAndView getUserList(HttpServletRequest request)
/*     */   {
/*  66 */     ModelAndView mv = new ModelAndView();
/*  67 */     String page = (request.getParameter("page") == null) || 
/*  68 */       ("".equals(request.getParameter("page"))) ? "1" : request
/*  69 */       .getParameter("page");
/*  70 */     String size = (request.getParameter("size") == null) || 
/*  71 */       ("".equals(request.getParameter("size"))) ? "20" : request
/*  72 */       .getParameter("size");
/*  73 */     HttpSession session = request.getSession();
/*  74 */     Admin t = (Admin)session.getAttribute("admin_user");
/*  75 */     if (t == null) {
/*  76 */       mv.setViewName("redirect:/manage/managelogin.do");
/*  77 */       return mv;
/*     */     }
/*  79 */     String[] clause = new String[0];
/*  80 */     String sql = " WHERE deleteFlag=0 ";
/*  81 */     Object[] obj = new Object[0];
/*  82 */     PagingResult pr = this.userService.selectBySqlPaging(clause, sql, obj, Integer.valueOf(Integer.parseInt(page)), Integer.valueOf(Integer.parseInt(size)));
/*  83 */     List<Map<Object, Object>> list = new ArrayList();
/*  84 */     for (Map<?, ?> map : pr.getResultList()) {
/*  85 */       String id = (Integer)map.get("user_id")+"";
/*  86 */       BaseExample ba = new BaseExample();
/*  87 */       ba.or().andEqualTo("poster_user", id).andEqualTo("DeleteFlag", Integer.valueOf(0));
/*  88 */       List<Map<?, ?>> a = this.posterService.selectByExample(ba);
/*  89 */       Map<Object, Object> m = new HashMap();
/*  90 */       if ((a == null) || (a.size() == 0)) {
/*  91 */         m.put("zt", "未上传");
/*     */       } else {
/*  93 */         m.put("zt", "已上传");
/*     */       }
/*  95 */       m.putAll(map);
/*  96 */       list.add(m);
/*     */     }
/*  98 */     int s = Integer.parseInt(page) - 1;
/*  99 */     int h = s * Integer.parseInt(size);
/* 100 */     mv.addObject("ss", Integer.valueOf(h));
/* 101 */     mv.addObject("list", list);
/* 102 */     mv.addObject("page", page);
/* 103 */     mv.addObject("size", size);
/* 104 */     mv.addObject("total", Integer.valueOf(pr.getTotalSize()));
/* 105 */     mv.addObject("url", "/back/users/index.jsp");
/* 106 */     mv.setViewName("/index.jsp");
/* 107 */     return mv;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   @RequestMapping({"edit"})
/*     */   public ModelAndView edit(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 116 */     String id = request.getParameter("user_id");
/* 117 */     ModelAndView mv = new ModelAndView();
/*     */     
/* 119 */     HttpSession session = request.getSession();
/* 120 */     Admin t = (Admin)session.getAttribute("admin_user");
/* 121 */     if (t == null) {
/* 122 */       mv.setViewName("redirect:/manage/managelogin.do");
/* 123 */       return mv;
/*     */     }
/* 125 */     Users obj = (Users)this.userService.selectByPrimaryKey(id);
/* 126 */     mv.addObject("obj", obj);
/* 127 */     mv.addObject("url", "/back/users/editorsc.jsp");
/* 128 */     mv.setViewName("/index.jsp");
/* 129 */     return mv;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   @RequestMapping({"editor"})
/*     */   public ModelAndView editor(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 139 */     ModelAndView mv = new ModelAndView();
/* 140 */     HttpSession session = request.getSession();
/* 141 */     Admin t = (Admin)session.getAttribute("admin_user");
/* 142 */     if (t == null) {
/* 143 */       mv.setViewName("redirect:/manage/managelogin.do");
/* 144 */       return mv;
/*     */     }
/*     */     
/*     */ 
/* 148 */     String id = request.getParameter("user_id");
/* 149 */     Users u = (Users)this.userService.selectByPrimaryKey(id);
/*     */     
/* 151 */     String user_tel = request.getParameter("user_tel");
/* 152 */     String user_email = request.getParameter("user_email");
/* 153 */     String user_name = request.getParameter("user_name");
/* 154 */     String user_identityCount = request.getParameter("user_identityCount");
/*     */     
/* 156 */     u.setUser_name(user_name);
/* 157 */     u.setUser_email(user_email);
/* 158 */     u.setUser_tel(user_tel);
/* 159 */     u.setUser_identityCount(user_identityCount);
/* 160 */     this.userService.updateByEntity(u);
/*     */     
/*     */ 
/*     */ 
/* 164 */     mv.setViewName("redirect:/users/edit.do?user_id=" + id);
/* 165 */     return mv;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   @RequestMapping({"del"})
/*     */   public ModelAndView fjDel(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 175 */     Map<String, Object> attributes = new HashMap();
/* 176 */     MappingJacksonJsonView view = new MappingJacksonJsonView();
/* 177 */     ModelAndView mv = new ModelAndView();
/*     */     
/*     */     try
/*     */     {
/* 181 */       String id = request.getParameter("user_id");
/*     */       
/*     */ 
/* 184 */       HttpSession session = request.getSession();
/* 185 */       Admin t = (Admin)session.getAttribute("admin_user");
/* 186 */       if (t == null) {
/* 187 */         mv.setViewName("redirect:/manage/managelogin.do");
/* 188 */         return mv;
/*     */       }
/*     */       
/* 191 */       Users obj = (Users)this.userService.selectByPrimaryKey(id);
/* 192 */       obj.setDeleteFlag(1);
/* 193 */       this.userService.updateByEntity(obj);
/*     */       
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/* 199 */       attributes.put("code", "0");
/* 200 */       attributes.put("msg", "ok");
/* 201 */       view.setAttributesMap(attributes);
/* 202 */       mv.setView(view);
/* 203 */       return mv;
/*     */     }
/*     */     catch (Exception e) {
/* 206 */       attributes.put("code", "1");
/* 207 */       attributes.put("msg", "系统错误");
/* 208 */       view.setAttributesMap(attributes);
/* 209 */       mv.setView(view); }
/* 210 */     return mv;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   @RequestMapping({"tongguo"})
/*     */   public ModelAndView tongguo(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 223 */     Map<String, Object> attributes = new HashMap();
/* 224 */     MappingJacksonJsonView view = new MappingJacksonJsonView();
/* 225 */     ModelAndView mv = new ModelAndView();
/*     */     
/*     */     try
/*     */     {
/* 229 */       String id = request.getParameter("acc_id");
/* 230 */       String msg = request.getParameter("msg");
/*     */       
/* 232 */       HttpSession session = request.getSession();
/* 233 */       Admin t = (Admin)session.getAttribute("admin_user");
/* 234 */       if (t == null) {
/* 235 */         mv.setViewName("redirect:/manage/managelogin.do");
/* 236 */         return mv;
/*     */       }
/*     */       
/* 239 */       Accessory obj = (Accessory)this.accessoryService.selectByPrimaryKey(id);
/* 240 */       obj.setAccessory_zt("3");
/* 241 */       obj.setAccessory_con(msg);
/* 242 */       obj.setAddTime(new Date());
/* 243 */       this.accessoryService.updateByEntity(obj);
/*     */       
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/* 249 */       attributes.put("code", "0");
/* 250 */       attributes.put("msg", "ok");
/* 251 */       view.setAttributesMap(attributes);
/* 252 */       mv.setView(view);
/* 253 */       return mv;
/*     */     }
/*     */     catch (Exception e) {
/* 256 */       attributes.put("code", "1");
/* 257 */       attributes.put("msg", "系统错误");
/* 258 */       view.setAttributesMap(attributes);
/* 259 */       mv.setView(view); }
/* 260 */     return mv;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   @RequestMapping({"jujue"})
/*     */   public ModelAndView jujue(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 273 */     Map<String, Object> attributes = new HashMap();
/* 274 */     MappingJacksonJsonView view = new MappingJacksonJsonView();
/* 275 */     ModelAndView mv = new ModelAndView();
/*     */     
/*     */     try
/*     */     {
/* 279 */       String id = request.getParameter("acc_id");
/* 280 */       String msg = request.getParameter("msg");
/*     */       
/* 282 */       HttpSession session = request.getSession();
/* 283 */       Admin t = (Admin)session.getAttribute("admin_user");
/* 284 */       if (t == null) {
/* 285 */         mv.setViewName("redirect:/manage/managelogin.do");
/* 286 */         return mv;
/*     */       }
/*     */       
/* 289 */       Accessory obj = (Accessory)this.accessoryService.selectByPrimaryKey(id);
/* 290 */       obj.setAccessory_zt("2");
/* 291 */       obj.setAccessory_con(msg);
/* 292 */       obj.setAddTime(new Date());
/* 293 */       this.accessoryService.updateByEntity(obj);
/*     */       
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/* 299 */       attributes.put("code", "0");
/* 300 */       attributes.put("msg", "ok");
/* 301 */       view.setAttributesMap(attributes);
/* 302 */       mv.setView(view);
/* 303 */       return mv;
/*     */     }
/*     */     catch (Exception e) {
/* 306 */       attributes.put("code", "1");
/* 307 */       attributes.put("msg", "系统错误");
/* 308 */       view.setAttributesMap(attributes);
/* 309 */       mv.setView(view); }
/* 310 */     return mv;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   @RequestMapping({"show"})
/*     */   public ModelAndView show(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 323 */     String id = request.getParameter("user_id");
/*     */     
/* 325 */     HttpSession session = request.getSession();
/* 326 */     ModelAndView mv = new ModelAndView();
/* 327 */     Admin t = (Admin)session.getAttribute("admin_user");
/* 328 */     if (t == null) {
/* 329 */       mv.setViewName("redirect:/manage/managelogin.do");
/* 330 */       return mv;
/*     */     }
/* 332 */     Users obj = (Users)this.userService.selectByPrimaryKey(id);
/* 333 */     BaseExample ba = new BaseExample();
/* 334 */     ba.or().andEqualTo("poster_user", id);
/* 335 */     ba.leftJoinOn("Accessory", "Accessory_id", "poster_accid").or(0).andEqualTo("Accessory", "DeleteFlag", "0");
/* 336 */     ba.or(0).andEqualTo("deleteFlag", "0");
/* 337 */     ba.setOrderByClause("Accessory.addTime DESC");
/* 338 */     List<Map<?, ?>> l = this.posterService.selectByExample(ba);
/*     */     
/*     */ 
/* 341 */     BaseExample ba1 = new BaseExample();
/* 342 */     ba1.or().andEqualTo("abstract_user", id);
/* 343 */     ba1.leftJoinOn("Accessory", "Accessory_id", "abstract_accid").or(0).andEqualTo("Accessory", "DeleteFlag", "0");
/* 344 */     ba1.or(0).andEqualTo("deleteFlag", "0");
/* 345 */     ba1.setOrderByClause("Accessory.addTime DESC");
/* 346 */     List<Map<?, ?>> l1 = this.abstractService.selectByExample(ba1);
/*     */     
/*     */ 
/*     */ 
/*     */ 
/* 351 */     List<Map<?, ?>> l2 = new ArrayList();
/*     */     
/* 353 */     mv.addObject("poster", l);
/* 354 */     mv.addObject("list", l1);
/* 355 */     mv.addObject("obj", obj);
/* 356 */     mv.addObject("url", "/back/users/show.jsp");
/* 357 */     mv.setViewName("/index.jsp");
/* 358 */     return mv;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public static Date strToDate(String strDate)
/*     */   {
/* 367 */     SimpleDateFormat formatter = null;
/* 368 */     formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
/* 369 */     ParsePosition pos = new ParsePosition(0);
/* 370 */     Date strtodate = formatter.parse(strDate, pos);
/* 371 */     return strtodate;
/*     */   }
/*     */ }


/* Location:              C:\Users\chengkp\Desktop\interwar\WEB-INF\classes\!\com\controller\back\AdminController.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */